package com.sefonsoft.dataanalysis.service.impl.stjj.mhwz;

import java.util.Map;

import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.springframework.stereotype.Service;

import com.sefonsoft.dataanalysis.model.stjj.mhwz.StjjMhwzZfxxgkzlBean;
import com.sefonsoft.dataanalysis.service.impl.BaseService;
import com.sefonsoft.dataanalysis.service.model.Datas;
import com.sefonsoft.dataanalysis.utils.Tools;

/**
 * 政府信息公开专栏Service
 */
@Service
public class StjjMhwzZfxxgkzlBeanService extends BaseService<StjjMhwzZfxxgkzlBean> {

	@Override
	public Datas<StjjMhwzZfxxgkzlBean> dataAnalysisByHtml(Document doc) {
		StjjMhwzZfxxgkzlBean sjb = new StjjMhwzZfxxgkzlBean();
		Elements  el = doc.select("table");
		String text = el.eq(0).text().replaceAll(" ","").replaceAll("\\s+","");
		sjb.setLy(text.substring(text.indexOf("发文机构：")+5, text.indexOf("组配分类：")));
		sjb.setBt(text.substring(text.indexOf("名称：")+3, text.indexOf("文号：")));
		sjb.setFbsj(text.substring(text.indexOf("发文日期：")+5, text.indexOf("主题词：")));
		sjb.setZw(text.substring(text.indexOf("字体大小")+"字体大小[大中小]".length(), text.length()));
		sjb.setId(Tools.createUUID());
		return new Datas<StjjMhwzZfxxgkzlBean>(sjb);
	}

	@Override
	public Class<StjjMhwzZfxxgkzlBean> getTClass() {
		return StjjMhwzZfxxgkzlBean.class;
	}
	
	@Override
	public void generateMap(Map<String, Object> map) {
		//作查询条件组装
		
	}
	
	@Override
	public Datas<StjjMhwzZfxxgkzlBean> dataAnalysisByJson(String jsonStr) {
		/**
		 * 做json特殊处理
		 */
		return null;
	}
	
	@Override
	public Type getSourceType() {
		return Type.HTML;
	}

}
